//
//  WKCell.m
//  WKjump
//
//  Created by TOPTEAM on 2017/4/17.
//  Copyright © 2017年 TOPTEAM. All rights reserved.
//

#import "WKCell.h"
#import "WKQRTool.h"

#define ScreenBounds [[UIScreen mainScreen] bounds]
#define ScreenWidth ScreenBounds.size.width
#define ScreenHeight ScreenBounds.size.height
#import "Masonry.h"
#define RGB(__r, __g, __b)  [UIColor colorWithRed:(1.0*(__r)/255)\
green:(1.0*(__g)/255)\
blue:(1.0*(__b)/255)\
alpha:1.0]

#define WIDTH_IMGV   24
@interface WKCell ()

@property (nonatomic,strong) UILabel* lab_tip;
@property (strong, nonatomic)  UIImageView *codeImv;

@end

@implementation WKCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        self.backgroundColor = [UIColor colorWithRed:241/255.0 green:254/255.0 blue:249/255.0 alpha:1];
        [self initView];
    }
    return self;
}

- (void)initView{
    
    
  
    
    
    _lab_tip= [UILabel new];
    _lab_tip.textColor = [UIColor  orangeColor];
    _lab_tip.font = [UIFont systemFontOfSize:15];
    _lab_tip.numberOfLines=0;
    _lab_tip.text = @"加载中....";
    _lab_tip.textAlignment = NSTextAlignmentCenter;
    _lab_tip.backgroundColor = [UIColor clearColor];
    [self addSubview:_lab_tip];
    [_lab_tip mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(10);
        make.left.equalTo(self.mas_left).offset(ScreenWidth/2.0+10);
        make.width.mas_equalTo(@(ScreenWidth/2.0-20));
        make.bottom.equalTo(self.mas_bottom);
    }];
    
    _codeImv=[[UIImageView alloc]init];
    _codeImv.frame=CGRectMake(0, 0, ScreenWidth/2.0, ScreenWidth/2.0);
    [self addSubview:_codeImv];
    


    
    
    
}


-(void)relayOutUIWithType:(TypeModel *)type{
    

    
    NSArray *colors = @[[UIColor colorWithRed:10.0/255.0 green:10.0/255.0 blue:10.0/255.0 alpha:1], [UIColor colorWithRed:190.0/255.0 green:190.0/255.0 blue:190.0/255.0 alpha:1]];
    
    NSString *iconsPath = [NSBundle mainBundle].bundlePath;
    iconsPath = [iconsPath stringByAppendingString:@"/Expression.bundle/"];

     UIImage *img = [WKQRTool QR_ForString:@"http://weixin.qq.com/r/l609JdDEg438rZRG9-iF" withSizeType:type.kQRCodeSizeType1 drawType:type.kQRCodeDrawType1 gradientType:type.kQRCodeGradientType1 gradientColors:colors iconsPath:iconsPath];
    
    self.codeImv.image = img;
    
    NSString * kQRCodeSize;
    if (type.kQRCodeSizeType1==1) {
        kQRCodeSize=@"Small-Size";
    }else if(type.kQRCodeSizeType1==2){
        kQRCodeSize=@"Normal-Size";
    }else{
        kQRCodeSize=@"Big-Size";
    }
    
    
    NSString *DrawType;
    if (type.kQRCodeDrawType1==1) {
        DrawType=@"None";
    }else if(type.kQRCodeDrawType1==2){
        DrawType=@"正方形";
    }else if(type.kQRCodeDrawType1==3){
        DrawType=@"圆";
    }else{
        DrawType=@"图标";
    }
    
    NSString * GradientType;
    if (type.kQRCodeGradientType1==1) {
        GradientType=@"纯色";
    }else if(type.kQRCodeGradientType1==2){
        GradientType=@"水平渐变";
    }else{
        GradientType=@"对角线渐变";
    }
    
    _lab_tip.text=[NSString stringWithFormat:@"%@\n%@\n%@",kQRCodeSize,DrawType,GradientType];
   
}



+(CGFloat)computeHeight:(id)data
{

    return ScreenWidth/2.0;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
